package com.jz.community.basecomm.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by Tony.Fan on 2018/3/27 16:24
 */
public class DateUtils {


    /*
     * 将时间戳转换为时间
     */
    public static String stampToDate(String times) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd ");
        Date date = new Date(Long.parseLong(times));
        return simpleDateFormat.format(date);
    }

    public static String stampToDate(String times, String format) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
        Date date = new Date(Long.parseLong(times));
        return simpleDateFormat.format(date);
    }

    //获得当天24点时间戳
    public static long getTimesNight() {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, 24);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return (cal.getTimeInMillis());
    }

}
